I need to obtain the linked object ID's of the object via DXL Scripting

Hello,

I need to obtain the Object IDs of the linked objects in the module.

For e.g.: If a module contains object ID as - SYS_403, It has two links which in turn points to other Object Id's - SR-9.

I have obtain those object IDs in a separate column as SYS_SR_9.

Please help.


KBSri - Tue Feb 25 06:50:47 EST 2014

Re: I need to obtain the linked object ID's of the object via DXL Scripting
Mathias Mamsch - Tue Feb 25 08:02:34 EST 2014

If you use the search on the forum you will find a lot of examples for that. Search for something like "iterate links" or "get link target". Please use the search before posting. Regards, Mathias

Re: I need to obtain the linked object ID's of the object via DXL Scripting
GregM_dxler - Tue Feb 25 10:35:01 EST 2014

I agree with Mathias.  Seems like this forum is starting to become a dxl script request site instead of a place to learn about dxl.

Instead of a dxl script for this, it seems like DOORS already provides what you want.  Use the Analysis Wizard or the Link Analysis tool.  You can set the depth in the Link Analysis tool to recursively go from link to link.  This is also a good way to get a framework of what you want to do in dxl and then edit it to your liking.

Maybe I'm just getting crabby from the long winter.

Greg

Re: I need to obtain the linked object ID's of the object via DXL Scripting
KBSri - Tue Feb 25 23:05:10 EST 2014

GregM_dxler - Tue Feb 25 10:35:01 EST 2014

I agree with Mathias.  Seems like this forum is starting to become a dxl script request site instead of a place to learn about dxl.

Instead of a dxl script for this, it seems like DOORS already provides what you want.  Use the Analysis Wizard or the Link Analysis tool.  You can set the depth in the Link Analysis tool to recursively go from link to link.  This is also a good way to get a framework of what you want to do in dxl and then edit it to your liking.

Maybe I'm just getting crabby from the long winter.

Greg

It s not script request!!!! We guys are new to scripting...We are in assumption that we will get an idea over here!!

Thanks for your replies.

Re: I need to obtain the linked object ID's of the object via DXL Scripting
KBSri - Wed Feb 26 05:28:28 EST 2014

KBSri - Tue Feb 25 23:05:10 EST 2014

It s not script request!!!! We guys are new to scripting...We are in assumption that we will get an idea over here!!

Thanks for your replies.

Hello All,

I am not requesting for a script. I got stuck up here. Please help if u wish.

I need to obtains the Object IDs of all the incoming links of the objects.

But I am able to obtain only one objects ID, but if there are many object IDs for the object it is not able to obtain.

Please help.

bIngoingLinkObjIDs = false        
              

string derivedObjIDsSource = ""
string derivedObjIDsTarget = ""
string derivedObjIDsSourceTarget = ""
            
for l in obj <- "*" do

{
                    bIngoingLinkObjIDs = true
                    Object ObjnameSource = source(l)
                    Object ObjnameTarget = target(l)
                
                    derivedObjIDsSource = identifier(ObjnameSource)
                    derivedObjIDsTarget = identifier(ObjnameTarget)
                    
                    print "\nDerived Object IDs:" derivedObjIDsSource "_" derivedObjIDsTarget "\n"
                    derivedObjIDsSourceTarget = derivedObjIDsSource "_" derivedObjIDsTarget
}

Re: I need to obtain the linked object ID's of the object via DXL Scripting
adevicq - Wed Feb 26 05:45:28 EST 2014

KBSri - Wed Feb 26 05:28:28 EST 2014

Hello All,

I am not requesting for a script. I got stuck up here. Please help if u wish.

I need to obtains the Object IDs of all the incoming links of the objects.

But I am able to obtain only one objects ID, but if there are many object IDs for the object it is not able to obtain.

Please help.

bIngoingLinkObjIDs = false        
              

string derivedObjIDsSource = ""
string derivedObjIDsTarget = ""
string derivedObjIDsSourceTarget = ""
            
for l in obj <- "*" do

{
                    bIngoingLinkObjIDs = true
                    Object ObjnameSource = source(l)
                    Object ObjnameTarget = target(l)
                
                    derivedObjIDsSource = identifier(ObjnameSource)
                    derivedObjIDsTarget = identifier(ObjnameTarget)
                    
                    print "\nDerived Object IDs:" derivedObjIDsSource "_" derivedObjIDsTarget "\n"
                    derivedObjIDsSourceTarget = derivedObjIDsSource "_" derivedObjIDsTarget
}

Hi,

If you loop through links and try to get the source object you will get a "null" value if the corresponding module is not loaded.

I suggest you to use a "LinkRef" instead of a "Link":

LinkRef l
ModName_ mnSrc
int nAbs
Module mSrc 
Object oSrc

for l in o<-"your link module" do {
    nAbs = sourceAbsNo(l)           // Gets the source object absolute number
    mnSrc = source(l)               // Gets the source module name
    mSrc = load(moduleVersion(mnSrc), false) // Loads the source module
    oSrc = object(nAbs, mSrc)       // Reads the source object
}

Play with these perms and you will probably find a solution...

In addition, if you need to store more than one value, you should use a Skip list. check the DXL help. It is well documented.

Regards,

Alain

Re: I need to obtain the linked object ID's of the object via DXL Scripting
KBSri - Wed Feb 26 06:17:38 EST 2014

adevicq - Wed Feb 26 05:45:28 EST 2014

Hi,

If you loop through links and try to get the source object you will get a "null" value if the corresponding module is not loaded.

I suggest you to use a "LinkRef" instead of a "Link":

LinkRef l
ModName_ mnSrc
int nAbs
Module mSrc 
Object oSrc

for l in o<-"your link module" do {
    nAbs = sourceAbsNo(l)           // Gets the source object absolute number
    mnSrc = source(l)               // Gets the source module name
    mSrc = load(moduleVersion(mnSrc), false) // Loads the source module
    oSrc = object(nAbs, mSrc)       // Reads the source object
}

Play with these perms and you will probably find a solution...

In addition, if you need to store more than one value, you should use a Skip list. check the DXL help. It is well documented.

Regards,

Alain

Thanks a ton. I need this kind of help to improve myself. Yes your idea of replacing the links with linkRef can be done.

I need to get the Target Object IDs of the source Object.

For e.g: Source Object ID has SYS_49 and it has two ingoing links such as SR_23 and XR_76.I need to get both of them stored in an string as SYS_49_SR_29; SYS_49_XR_76 respectively.

Re: I need to obtain the linked object ID's of the object via DXL Scripting
GregM_dxler - Wed Feb 26 09:01:59 EST 2014

KBSri - Wed Feb 26 06:17:38 EST 2014

Thanks a ton. I need this kind of help to improve myself. Yes your idea of replacing the links with linkRef can be done.

I need to get the Target Object IDs of the source Object.

For e.g: Source Object ID has SYS_49 and it has two ingoing links such as SR_23 and XR_76.I need to get both of them stored in an string as SYS_49_SR_29; SYS_49_XR_76 respectively.

KBSri,

The above example from adevicq is good to get link information.  A couple of things to note though.

If you want to get all incoming links, then use "*" for the "your link module".  Otherwise it will only loop through incoming links through "your link module".  Many times what happens is people will make links without linksets made up and DOORS will put the link information in a DOORS links link module.  Same thing is true with looping through outgoing links, using "*" for the "your link module" will go through all links, not just the ones in the link module.

For incoming links, you need to have at least read access to the module the link is sourced from.  If you don't have read access, then it will skip the links.  This has bit me as well.  The easiest way to tell if there is an incoming link that you don't see, is to try and delete the object.  DOORS will tell you it can't be deleted because there is an incoming link.

I still don't understand why you don't use the link tools in DOORS to help you.  Run the link wizard to have it populate a column with the object IDs of the source of the incoming links.  Then you can right click on the column heading, select properties and then look at the dxl code it writes.  You can copy and paste this into your editor to use as a starting point.  Maybe it is because of the previous issues I've mentioned as to why you can not do this?

Hope this helps,

Greg

Re: I need to obtain the linked object ID's of the object via DXL Scripting
GregM_dxler - Wed Feb 26 09:07:42 EST 2014

KBSri - Wed Feb 26 05:28:28 EST 2014

Hello All,

I am not requesting for a script. I got stuck up here. Please help if u wish.

I need to obtains the Object IDs of all the incoming links of the objects.

But I am able to obtain only one objects ID, but if there are many object IDs for the object it is not able to obtain.

Please help.

bIngoingLinkObjIDs = false        
              

string derivedObjIDsSource = ""
string derivedObjIDsTarget = ""
string derivedObjIDsSourceTarget = ""
            
for l in obj <- "*" do

{
                    bIngoingLinkObjIDs = true
                    Object ObjnameSource = source(l)
                    Object ObjnameTarget = target(l)
                
                    derivedObjIDsSource = identifier(ObjnameSource)
                    derivedObjIDsTarget = identifier(ObjnameTarget)
                    
                    print "\nDerived Object IDs:" derivedObjIDsSource "_" derivedObjIDsTarget "\n"
                    derivedObjIDsSourceTarget = derivedObjIDsSource "_" derivedObjIDsTarget
}

One more thing on your posted code.

The loop is going through incoming links.  source(l) works to find the source of the incoming link, but target(l) is used to find the object where the outgoing link goes to.  The target of the incoming link is the object it is working on.  That is, it would be identifier(obj).

If you want to loop through outgoing links, then you would use identifier(obj) for the "source" of the link and then target(l) to find the object to where the link goes.

Hope this helps,

Greg

Re: I need to obtain the linked object ID's of the object via DXL Scripting
KBSri - Thu Feb 27 05:03:06 EST 2014

GregM_dxler - Wed Feb 26 09:07:42 EST 2014

One more thing on your posted code.

The loop is going through incoming links.  source(l) works to find the source of the incoming link, but target(l) is used to find the object where the outgoing link goes to.  The target of the incoming link is the object it is working on.  That is, it would be identifier(obj).

If you want to loop through outgoing links, then you would use identifier(obj) for the "source" of the link and then target(l) to find the object to where the link goes.

Hope this helps,

Greg

Greg thanks a lot for your invaluable suggestions for newbie.But what I require is for incoming links only.

Now I am able to fetch only one of the ObjectID corresponding to the Source module Object ID,but what I am not able to do is store all the IDs in the same string.

More over I have used the link tools in DOORS but what I need is in DXL Scripting.

Thanks a ton in advance.Please suggest.

Re: I need to obtain the linked object ID's of the object via DXL Scripting
GregM_dxler - Thu Feb 27 09:03:16 EST 2014

KBSri - Thu Feb 27 05:03:06 EST 2014

Greg thanks a lot for your invaluable suggestions for newbie.But what I require is for incoming links only.

Now I am able to fetch only one of the ObjectID corresponding to the Source module Object ID,but what I am not able to do is store all the IDs in the same string.

More over I have used the link tools in DOORS but what I need is in DXL Scripting.

Thanks a ton in advance.Please suggest.

It sounds like the problem is not in getting the links but to save the link information together.  What your code is doing is overwritting what is currently there.  The simpliest way is when you save the link information for one link you just add it to the string.  So instead of your command

derivedObjIDsSourceTarget = derivedObjIDsSource "_" derivedObjIDsTarget
 You use

derivedObjIDsSourceTarget = derivedObjIDsSourceTarget ", " derivedObjIDsSource "_" derivedObjIDsTarget

A better and more efficient way to handle it is to use a buffer instead of a string variable.  To do this, the declaration would be

Buffer derivedObjIDsSourceTarget = create

Then when you want to add stuff to it, you use the command

derivedObjIDsSourceTarget += ", " derivedObjIDsSource "_" derivedObjIDsTarget

And then for cleanup you would use the following command at the end of your program.

delete derivedObjIDsSourceTarget

Hope this helps,

Greg